<?php
/**
 * Object 
 * 所有类的父类.用于定义所有类都会用到的函数
 * @package 
 * @version $id$
 * @copyright 
 * @author lovise <lovise.lu@gmail.com> 
 * @license PHP Version 3.0 {@link http://www.php.net/license/3_0.txt}
 */
class Object {

	function __construct() {
	}


	function requestAction($url) {
		if (empty($url)) {
			return false;
		}
		if (!class_exists('Router')) {
			require MINICAKE.DS.'lib'.DS.'router.php';
		}
		$dispatcher = new Dispatcher();
		$dispatcher->autoRender = false;
		return $dispatcher->dispatch($url);
	}

/**
 * Calls a method on this object with the given parameters. Provides an OO wrapper
 * for `call_user_func_array`
 *
 * @param string $method  Name of the method to call
 * @param array $params  Parameter list to use when calling $method
 * @return mixed  Returns the result of the method call
 * @access public
 */
	function dispatchMethod($method, $params = array()) {
		switch (count($params)) {
			case 0:
				return $this->{$method}();
			case 1:
				return $this->{$method}($params[0]);
			case 2:
				return $this->{$method}($params[0], $params[1]);
			case 3:
				return $this->{$method}($params[0], $params[1], $params[2]);
			case 4:
				return $this->{$method}($params[0], $params[1], $params[2], $params[3]);
			case 5:
				return $this->{$method}($params[0], $params[1], $params[2], $params[3], $params[4]);
			default:
				return call_user_func_array(array(&$this, $method), $params);
			break;
		}
	}

}
